#ifndef PAINTAREA_H
#define PAINTAREA_H
//????????VC???
#include <QtGui>
#include"coordinate.h"
#include "jwidget/jdialog.h"
#include <QDialog>

extern int butSize_H ;
extern int butSize_W ;
extern int FRONTWIDTH	    ;
extern int FRONTHEIGHT	   ;
extern int BKWIDTH	        ;
extern int BKHEIGHT       ;

#define BKCOLOR         RGB(128,10,10)	//?????
#define ROWCOUNT        12//12					//????
#define COLCOUNT        23//23					//????
#define BLANK_STATE     -1                  //??????????????
#define PHOTOCOUNT      6                                       //???????


class PaintArea : public QDialog
//class PaintArea : public JDialog
{
    Q_OBJECT
public:
    enum Shape {Line,Rectangle,RoundRect,Ellipse,Polygon,Polyline,Points,Arc,Path,Text,Pixmap};
    explicit PaintArea(QWidget *parent=0);

     ~PaintArea();


    QPushButton		*pNewButton	    ;
    QPushButton		*pCloseButton	;
    QPushButton		*pAnwserButton	;
    QPushButton		*pResetButton	;
    //QGridLayout     *pMainLayout	;
    QLabel		     *pNonLab	    ;
    PaintArea *gamepanel;
   // QWidget *timepanl;
    QWidget *mainpanl;
    QHBoxLayout *hLayout;

    void paintEvent(QPaintEvent *);

    void GameDraw(QPainter* p);
    void mousePressEvent(QMouseEvent *event);
    bool IsLink(int x1, int y1, int x2, int y2,QList<Coordinate> *path);
    bool X1_X2(int x1, int y1, int x2, int y2);
    bool Y1_Y2(int x1, int y1, int x2, int y2);
    bool OneCornerLink(int x1, int y1, int x2, int y2,QList<Coordinate> *path);
    bool TwoCornerLink(int x1, int y1, int x2, int y2,QList<Coordinate> *path);
    bool IsWin();
    bool findPair();

    void setShape(Shape);
    void setPen(QPen);
    void setBrush(QBrush);

private:
    Shape shape;
    QBrush brush;
    QPen pen;
    int difficulty;

    //???????????
    int         arrmap[ROWCOUNT][COLCOUNT];
    int*	m_map;        //???????????????????
    int		m_nRow;		  //?????????????
    int		m_nCol;		 //?????????????

    int		m_nX1;        //???????????????????
    int		m_nY1;	      //???????????????????
    QTimer *timer;
    Coordinate *stcoordi;
    Coordinate *endcoordi;
    QList<QPixmap> maplist;
    QList<Coordinate> *current;
    QList<Coordinate> *currentpath;
    QList<Coordinate> *mousecurrentpath;
    //QPainter *painter;
 public slots:
    void answer();
    bool reset();
    void StartNewGame();
};


#endif
